//
//  ISTThemeLabel.m
//  ChildHoodStemp
//
//  Created by 张 云鹤 on 14-8-26.
//
//

#import "ISTThemeLabel.h"

@interface ISTThemeLabel ()
{
    NSString *_colorStr;
    NSString *_backgroundColorStr;
}

@end

@implementation ISTThemeLabel

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [CNMultiThemeManager registerForThemeChange:self];
        // Initialization code
    }
    return self;
}

- (void)setBackgroundColor:(NSString *)backgroundColor andDefaultColor:(UIColor *)defaultColor{
    _backgroundColorStr = backgroundColor;
    UIColor *newColor = [CNMultiThemeManager colorForKey:backgroundColor];
    [self setBackgroundColor:newColor?newColor:defaultColor];
}

- (void)setTextColor:(NSString *)textColor andDefaultColor:(UIColor *)color{
    _colorStr = textColor;
    UIColor *newColor = [CNMultiThemeManager colorForKey:textColor];
    [self setTextColor:newColor?newColor:color];
}

-(void)applyTheme{
    if (_colorStr && _colorStr.length && [CNMultiThemeManager colorForKey:_colorStr]) {
        [self setTextColor:[CNMultiThemeManager colorForKey:_colorStr]];
    }
    if (_backgroundColorStr && _backgroundColorStr.length && [CNMultiThemeManager colorForKey:_backgroundColorStr]) {
        [self setBackgroundColor:[CNMultiThemeManager colorForKey:_backgroundColorStr]];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
